package com.apr.controller;

import com.apr.bean.Department;
import com.apr.mapper.DeptMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DeptController {

    private final DeptMapper deptMapper;

    public DeptController(DeptMapper deptMapper) {
        this.deptMapper = deptMapper;
    }

    @GetMapping("/dept/{id}")
    public Department SelDeptById(@PathVariable("id") Integer id) {
        return deptMapper.getDepartmentById(id);
    }

    @GetMapping("/dept")
    public Department insertDept(Department department) {
        deptMapper.insertDepartment(department);
        return department;
    }
}
